Program execution device

ABSTRACT

A program execution device capable of protecting a program against unauthorized analysis and alteration is provided. The program execution device includes an execution unit, a first protection unit, and a second protection unit. The execution unit executes a first program and a second program, and is connected with an external device that is capable of controlling the execution. The first protection unit disconnects the execution unit from the external device while the execution unit is executing the first program. The second protection unit protects the first program while the execution unit is executing the second program.

This application is a divisional of application Ser. No. 12/367,076,filed Feb. 6, 2009, the contents of which are hereby incorporated byreference, which is a continuation of application Ser. No. 10/569,414,which is the National Stage of International Application No.PCT/JP2004/012666, filed Aug. 26, 2004.

TECHNICAL FIELD

The present invention relates to techniques of protecting programsagainst unauthorized alteration and analysis.

BACKGROUND ART

In recent years, the widespread use of PCs and the Internet makes itpossible to copy or edit digital content such as software easily. Thisbeing so, tamper-resistant techniques are needed to protect softwareagainst unauthorized alteration and analysis.

Research has long been performed on tamper-resistant techniques. Forexample, an article “Protecting Software against Inverse Analysis andFalsification” in Nikkei Electronics, Jan. 5, 1998, pp. 209-220describes basic principles and concrete methods for preventingunauthorized software analysis. Also, an article “SoftwareTamper-resistant Techniques” in Fuji Xerox Technical Report, No. 13, pp.20-28 deals with technical problems and measures concerning preventionof unauthorized software analysis.

Despite this research, more various techniques for protecting programsagainst malicious users are still needed.

DISCLOSURE OF THE INVENTION

In view of the above problem, the present invention aims to provide aprogram execution device that can execute a program securely bypreventing unauthorized alteration and analysis.

The above aim can be achieved by a program execution device thatexecutes a first secure program which runs in a first security level anda second secure program which runs in a second security level lower thanthe first security level, including: an execution unit operable tooperate by switching between a first mode which is in the first securitylevel and a second mode which is in the second security level; anexternal device disconnection unit operable to disconnect the executionunit from an external device according to an instruction of the firstsecure program; and a protection unit operable to protect the secondsecure program. According to this construction, programs can beprotected from both external attacks using hardware and attacks usingsoftware. Also, a high level of security can be achieved bydisconnecting the external device.

Here, the program execution device may further include an interruptdetection unit operable to detect an interrupt, wherein the protectionunit includes a memory area in which the execution unit writes data whenoperating according to the second secure program, and when the interruptdetection unit detects an interrupt while the execution unit isoperating according to the second secure program, the protection unitencrypts the data written in the memory area, and, after the executionunit finishes processing the interrupt, decrypts the encrypted data inthe memory area before the execution unit resumes operating according tothe second secure program. According to this construction, the data inthe memory area is encrypted be fore control is transferred from thesecond secure program to another program. In this way, the data used bythe second secure program can be protected from other programs, with itbeing possible to prevent unauthorized analysis of the second secureprogram using software. Also, memory usage can be reduced by encryptingonly the data in the memory area. This enables a device, e.g. a mobiletelephone or a PDA, whose resources such as the CPU processing speed andthe memory capacity are limited, to maintain a high level of security.

Here, the second secure program may include a call instruction forcalling the first secure program, wherein the execution unit, accordingto the call instruction, passes the second tamper detection value, astart address of the at least one part of the second secure program, anda size of the at least one part of the second secure program, to thefirst secure program.

Here, before the execution unit executes the call instruction, theprotection unit may disable interrupt processing by the execution unit,wherein the execution unit, (a) according to the call instruction,passes an encrypted program key to the first secure program, (b)according to the first secure program, decrypts the encrypted programkey received from the second secure program using a master key includedin the first secure program, and passes the decrypted program key to thesecond secure program, if the first tamper detection value and thesecond tamper detection value are same, and (c) according to the secondsecure program, decrypts an encrypted part of the second secure programusing the decrypted program key received from the first secure program,and then deletes the decrypted program key, and after the execution unitdeletes the decrypted program key, the protection unit enables theinterrupt processing by the execution unit.

According to these constructions, no interrupt is accepted until theprogram key for decrypting the encrypted program is deleted. Thus, theprogram key is protected from unauthorized analysis which is performedby means of an interrupt, with it being possible to prevent unauthorizedanalysis of the second secure program.

Here, the execution unit, according to the first secure program, mayperform a hash operation on at least one part of the second secureprogram using a secret key to calculate a first tamper detect ion value,compare the first tamper detection value with a second tamper detectionvalue which has been calculated based on the at least one part of thesecond secure program upon generation of the second secure program, andterminate the operation if the first tamper detection value and thesecond tamper detection value are different, and continue the operationif the first tamper detection value and the second tamper detectionvalue are same.

According to this construction, the execution unit terminates theoperation if the second secure program is judged as being tampered with.This minimizes damage in the case where the second secure program hasbeen tampered with.

Also, the second secure program contains a tamper detection valuegenerated based on at least one part of the second secure program. Thisbeing so, when the second secure program needs to be changed such aswhen the second secure program has been tampered with, the change can bemade to the second secure program alone without changing otherprocessing means of the program execution device.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 shows an overall construction of a secure processing system towhich an embodiment of the present invention relates.

FIG. 2 is a block diagram showing a construction of a certificateauthority device shown in FIG. 1.

FIG. 3 is a flowchart showing an operation of a compiler shown in FIG.2.

FIG. 4 is a block diagram showing a construction of a memory card shownin FIG. 1.

FIG. 5 is a block diagram showing a construction of a portable terminalshown in FIG. 1.

FIG. 6 shows programs stored in a memory shown in FIG. 5.

FIG. 7 shows a data structure of a second secure processing programshown in FIG. 6.

FIG. 8 shows a data structure of a calling program shown in FIG. 7.

FIG. 9 is a flowchart showing a procedure of an interrupt handler shownin FIG. 7.

FIG. 10 shows a data structure of a first secure processing programshown in FIG. 6.

FIG. 11 shows a data structure of a vector table shown in FIG. 6.

FIG. 12 is a flowchart showing an operation of a CPU shown in FIG. 5.

FIG. 13 is a flowchart showing a music data playback procedure.

FIG. 14 is a flowchart showing the music data playback procedure.

FIG. 15 is a flowchart showing the music data playback procedure.

FIG. 16 is a flowchart showing the music data playback procedure.

FIG. 17 is a flowchart showing the music data playback procedure.

FIG. 18 is a flowchart showing an authentication procedure.

FIG. 19 is a flowchart showing an operation of the CPU when an interruptoccurs.

BEST MODE FOR CARRYING OUT THE INVENTION

The following describes an embodiment of the present invention indetail, with reference to drawings.

-   1. Construction of a Secure Processing System 1

FIG. 1 shows an overall construction of a secure processing system 1 towhich the embodiment of the pre sent invention relates. In the drawing,the secure processing system 1 is roughly made up of a certificateauthority device 100, a ROM writer 200, a portable terminal 300, and amemory card 400.

The secure processing system 1 protects a program which is executed inthe portable terminal 300 from unauthorized analysis and alteration. Theprogram to be protected is generated in the certificate authority device100 and written to a ROM by the ROM writer 200. The ROM carrying theprogram is then installed in the portable terminal 300.

In this embodiment, the program to be protected is an encrypted musicdata decryption program for decrypting encrypted music data recorded onthe memory card 400, as one example.

-   -   1.1. Certificate Authority Device 100

The certificate authority device 100 generates a second secureprocessing program that includes an area allocation program 511, aninterrupt disable program 512, a calling program 513, a key receptionprogram 514, an execution flag 515, an interrupt handler 518, adecryption program 516, and a secure program shown in FIG. 7. The secureprogram includes an encrypted music data decryption program 524 whichneeds to be protected. The generated second secure processing program iswritten on the ROM by the ROM writer 200 and installed in the portableterminal 300. Each of the programs is described in detail later.

FIG. 2 shows a construction of the certificate authority device 100. Inthe drawing, the certificate authority device 100 includes a compiler101, a program encryption unit 102, a key encryption unit 103, a hashvalue calculation unit 104, a data embedment unit 105, a storage unit106, and a transmission unit 107.

The certificate authority device 100 is actually realized by a computersystem that includes a microprocessor, a ROM, a RAM, a hard disk unit, adisplay unit, and a keyboard. The functions of the certificate authoritydevice 100 are realized by the microprocessor executing a computerprogram stored on the RAM or the hard disk unit.

-   -   -   (1) Compiler 101

The compiler 101 receives an input of source code of a protectionprogram, the calling program 513, the decryption program 516, and thesecure program. The protection program is made up of the area allocationprogram 511, the interrupt disable program 512, the key receptionprogram 514, the execution flag 515, and the interrupt handler 518. Thecalling program 513 is used for sending data that is needed to detectwhether the second secure processing program has been tampered with. Thecalling program 513 contains a start address of a TRS area program on amemory of the portable terminal 300. The TRS area program corresponds tothe decryption program 516 and an encrypted program 517 of the secondsecure processing program. The encrypted program 517 is generated byencrypting the secure program.

Upon receiving the source code of the calling program 513, thedecryption program 516, the secure program, and the protection program,the compiler 101 compiles each of the programs.

FIG. 3 is a flowchart showing an operation of compiling a program by thecompiler 101.

The compiler 101 performs lexical analysis (S621) and syntactic analysis(S622). Finally, the compiler 101 generates binary data representing aprogram that is executable by a computer (S623).

The compiler 101 outputs binary data of the calling program 513 andbinary data of the protection program to the data embedment unit 105.The compiler 101 also outputs binary data of the decryption program 516and binary data of the secure program to the program encryption unit102.

-   -   -   (2) Program Encryption Unit 102

The program encryption unit 102 receives the binary data of thedecryption program 516 and the binary data of the secure program. Theprogram encryption unit 102 also receives a program key. The programencryption unit 102 encrypts the secure program using the program keyaccording to encryption algorithm E1, to generate the encrypted program517. As one example, encryption algorithm E1 is an AES (Advanced Encryption Standard) algorithm. AES is well known in the art and so itsexplanation has been omitted here. Algorithms other than AES may also beused as encryption algorithm E1.

The program encryption unit 102 outputs the decryption program. 516 andthe encrypted program 517 to the data embedment unit 105 as the TRS areaprogram.

The program encryption unit 102 also outputs the TRS area program to thehash value calculation unit 104.

-   -   -   (3) Key Encryption Unit 103

The key encryption unit 103 receives the program key and a master key.

The key encryption unit 103 encrypts the program key using the masterkey according to encryption algorithm E1, to generate an encrypted key.The key encryption unit 103 outputs the encrypted key to the dataembedment unit 105.

-   -   -   (4) Hash Value Calculation Unit 104

The hash value calculation unit 104 calculates a hash value of at leastone part of the second secure processing program.

In this embodiment, the hash value calculation unit 104 receives the TRSarea program and a secret key, and calculates a hash value of the TRSarea program using the secret key according to a hash function.

For example, an algorithm used for HMAC (Keyed-Hashing for MessageAuthentication) may be used to calculate the hash value.

Let H be a hash function, K be a secret key, text be data to be hashed,opad be a character string made up of 64 number of byte values O×36, andipad be a character string made up of 64 number of byte values O×5C.This being the case, an algorithm for calculating a hash value can beexpressed as H(K XOR opad, H(K XOR ipad, text)).

The hash value calculation unit 104 also calculates a binary size of theTRS area program.

The hash value calculation unit 104 outputs the hash value and thebinary size to the data embedment unit 105.

-   -   -   (5) Data Embedment Unit 105

The data embedment unit 105 receives the binary data of the callingprogram 513 and the binary data of the protection program from thecompiler 101, and the hash value and the binary size from the hash valuecalculation unit 104. The data embedment unit 105 also receives theencrypted key from the key encryption unit 103, and the TRS area programfrom the program encryption unit 102.

The data embedment unit 105 embeds the hash value in the calling program513 as a tamper detection value. The data embedment unit 105 also embedsthe binary size and the encrypted key in the calling program 513. Thedata embedment unit 105 includes the resulting calling program 513 intothe protection program, and combines the protection program and the TRSarea program to form the second secure processing program. The dataembedment unit 105 writes the second secure processing program to thestorage unit 106.

-   -   -   (6) Storage Unit 106

The storage unit 106 stores the second secure processing program writtenby the data embedment unit 105.

-   -   -   (7) Transmission Unit 107

The transmission unit 107 outputs the second secure processing programstored in the storage unit 106, to the ROM writer 200.

-   -   1.2. ROM Writer 200

The ROM writer 200 is connected with the certificate authority device100. The ROM writer 200 receives the second secure processing programfrom the certificate authority device 100, and writes the second secureprocessing program to the ROM. The ROM on which the second secureprocessing program is written by the ROM writer 200 is then installed inthe portable terminal 300.

-   -   1.3. Memory Card 400

FIG. 4 shows a construction of the memory card 400. In the drawing, thememory card 400 includes a control unit 401, an input/output unit 402,an authentication unit 403, and an information storage unit 404.

-   -   -   (1) Input/output Unit 402

The input/output unit 402 performs transfer of data between the controlunit 401 and the portable terminal 300, when the memory card 400 isconnected to the portable terminal 300.

-   -   -   (2) Information Storage Unit 404

The information storage unit 404 has a data area 410 and a secure area420.

The data area 410 stores encrypted music data 411. The encrypted musicdata 411 is generated by encrypting MP3 music data using a title key 421according to encryption algorithm E1.

The secure area 420 stores the title key 421. The portable terminal 300can access the secure area 420 only when it has succeeded in mutualauthentication with the authentication unit 403.

Here, data which is stored in the information storage unit 404 may beencrypted using information unique to the memory card 400.

-   -   -   (3) Authentication Unit 403

The authentication unit 403 performs mutual authentication with theportable terminal 300 based on CPRM (Content Protection for RecordableMedia). If the mutual authentication is successful, the authenticationunit 403 establishes a shared key with the portable terminal 300, andoutputs the shared key to the control unit 401. CPRM is well known inthe art and so its explanation has been omitted here. Methods other thanCPRM may also be used for the mutual authentication.

-   -   -   (4) Control Unit 401

The control unit 401 performs transfer of data with the portableterminal 300 via the input/output unit 402. The control unit 401 permitsthe portable terminal 300 to access the data stored in the secure area420 only if the portable device 300 has succeeded in the mutualauthentication with the authentication unit 403. When outputting thedata stored in the secure area 420, the control unit 401 encrypts thedata using the shared key received from the authentication unit 403.

Meanwhile, the control unit 401 permits the portable terminal 300 toaccess the data stored in the data area 410 without the mutualauthentication.

-   -   1.4. Portable Terminal 300

FIG. 5 shows a construction of the portable terminal 300. In thedrawing, the portable terminal 300 includes a CPU 301, a debuggerinterface 302, a debugger disable circuit 303, an interrupt controller304, a memory 305, a memory card interface 306, an input unit 307, adisplay unit 308, a speaker 309, a decoder 310, a microphone 312, aconversion unit 313, a radio control unit 314, a radio unit 315, and anantenna 316. These components of the portable terminal 303 are connectedwith a bus 317. Also, the interrupt controller 304 is connected to theCPU 301 by an interrupt line 318.

The following describes each of the components of the portable terminal300.

-   -   -   (1) Debugger Disable Circuit 303 and Debugger Interface 302

The debugger disable circuit 303 is provided between the CPU 301 and thedebugger interface 302, to connect/disconnect the CPU 301 and thedebugger interface 302.

Upon receiving a debugger control signal indicating “enable” from theCPU 301, the debugger disable circuit 303 connects the CPU 301 to thedebugger interface 302. Upon receiving a debugger control signalindicating “disable” from the CPU 301, the debugger disable circuit 303disconnects the CPU 301 from the debugger interface 302.

When the CPU 301 and the debugger interface 302 are connected with eachother, an external debugger device connected to the debugger interface302 is enabled. If the CPU 301 and the debugger interface 302 aredisconnected from each other, the debugger device is disabled. Forexample, the debugger disable circuit 303 can be realized by a switch.Here, the connection/disconnection between the CPU 301 and the debuggerinterface 302 maybe made physically by means of a switch circuit or madeelectrically.

The debugger interface 302 is used for connecting the portable terminal300 and the debugger device.

-   -   -   (2) Memory 305

The memory 305 stores a first secure processing program 501, a secondsecure processing program 502, a vector table 503, a music playbackprogram 504, and an application 505, as shown in FIG. 6.

-   -   -   -   (A) Second Secure Processing Program 502

The second secure processing program 502 is generated by the certificateauthority device 100 and stored on the ROM by the ROM writer 200.

FIG. 7 shows the data structure of the second secure processing program502. The following explains each of the programs constituting the secondsecure processing program 502.

-   -   -   -   -   (Area Allocation Program 511)

The area allocation program 511 allocates a memory space, in the memory305, for dynamically allocating a memory area that is used whenexecuting the authentication program 523 and the encrypted music datadecryption program 524.

-   -   -   -   -   (Interrupt Disable Program 512)

The interrupt disable program 512 disables (i.e. masks) interrupts.

-   -   -   -   -   (Calling Program 513)

The calling program 513 calls the first secure processing program 501.

The calling program 513 includes tamper detection data that is composedof a tamper detection value 541, a TRS area start address 542, a binarysize 543, and an encrypted key 544, as shown in FIG. 8. When calling thefirst secure processing program 501, the calling program 513 also passesthis tamper detection data embedded by the data embedment unit 105 ofthe certificate authority device 100, to the first secure processingprogram 501.

Here, the tamper detection value 541 is the hash value calculated by thehash value calculation unit 104 of the certificate authority device 100for the TRS area program in the second secure processing program 502.

The TRS area start address 542 is the start address of the TRS areaprogram which is subjected to hash value calculation, in the memory 305.

The binary size 543 is the binary size of the TRS area program.

The encrypted key 544 is the program key encrypted by the key encryptionunit 103 of the certificate authority device 100 using the master key.

-   -   -   -   -   (Key Reception Program 514)

The key reception program 514 receives the program key from the firstsecure processing program 501, and passes the program key to thedecryption program 516.

-   -   -   -   -   (Execution Flag 515)

The execution flag 515 shows whether the secure program is beingexecuted or not. Immediately before the decryption program 516 decryptsthe encrypted program 517, the execution flag 515 is set to ONindicating that the secure program is being executed. When the executionof the secure program obtained by decrypting the encrypted program 517completes, the execution flag 515 is set to OFF.

-   -   -   -   -   (Decryption Program 516)

The decryption program 516 receives the program key from the keyreception program 514, and decrypts the encrypted program 517 using theprogram key according to decryption algorithm D1 to obtain the secureprogram. Here, decryption algorithm D1 is an inverse of encryptionalgorithm E1.

For example, a technique disclosed in International Patent ApplicationPublication No. WO 04/013744 (published on Feb. 12, 2004) maybe used fordecrypting the encrypted program 517. According to this technique, theencrypted program 517 is loaded to a memory and decrypted in units ofsmall portions. This prevents the whole secure program from existing onthe memory. Accordingly, even when an unauthorized party accesses datain the memory, it cannot obtain the whole secure program.

-   -   -   -   -   (Encrypted Program 517)

The encrypted program 517 is generated by encrypting the secure program.The secure program includes an interrupt enable program 521, an areainitialization program 522, an authentication program 523, the encryptedmusic data decryption program 524, an area key 525, an area encryptionprogram 526, an area decryption program 527, and an area release program528 shown in FIG. 7. In the encrypted program 517, the interrupt enableprogram 521, the area initialization program 522, the authenticationprogram 523, the area key 525, the area encryption program 526, the areadecryption program 527, and the area release program 528 protect theencrypted music data decryption program 524 from other programs.

(a) Interrupt Enable Program 521

The interrupt enable program 521 releases the disablement of interruptsmade by the interrupt disable program 512.

(b) Area Initialization Program 522

The area initialization program 522 initializes the memory spaceallocated by the area allocation program 511, to allocate, in the memoryspace, a memory area which is subjected to encryption.

This memory area is allocated to write data that is used duringexecution of the authentication program 523 and the encrypted music datadecryption program 524.

(c) Authentication Program 523

The authentication program 523 contains an authentication key 531.

The authentication program 523 performs one-way authentication to judgewhether the first secure processing program 501 is valid.

(d) Encrypted Music Data Decryption Program 524

The encrypted music data decryption program 524 decrypts the encryptedmusic data 411 stored on the memory card 400 using the title key 421according to decryption algorithm D1, to obtain the music data.

(e) Area Key 525

The area key 525 is used by the area encryption program 526 to encryptthe data in the memory area allocated by the area initialization program522, and by the area decryption program 527 to decrypt the encrypteddata in the memory area.

(f) Area Encryption Program 526

The area encryption program 526 encrypts the data in the memory areausing the area key 525 according to encryption algorithm E2. Here,encryption algorithm E2 enables faster processing than encryptionalgorithm E1. As one example, encryption algorithm E2 is an XORoperation. Alternatively, algorithms other than an XOR operation maybeused as encryption algorithm E2, which is determined based on the levelof security required and the processing capacity of the CPU 301.

The area encryption program 526 encrypts the data in the memory area,before the second secure processing program 502 calls the first secureprocessing program 501 to transfer control to the first secureprocessing program 501.

(g) Area Decryption Program 527

The area decryption program 527 decrypts the encrypted data in thememory area using the area key 525 according to decryption algorithm D2to obtain the original plaintext data, when control is returned from thefirst secure processing program 501 to the second secure processingprogram 502.

(h) Area Release Program 528

The area release program 528 releases the memory area allocated by thearea initialization program 522, and calls an exit function of the firstsecure processing program 501 to end a music data playback procedure.

-   -   -   -   -   (Interrupt Handler 518)

The interrupt handler 518 is executed when an interrupt occurs duringexecution of the second secure processing program 502. The interrupthandler 518 contains an encryption/decryption key (not illustrated).

FIG. 9 is a flowchart showing a procedure of the interrupt handler 518.Though the interrupt handler 518 is actually a computer program, FIG. 9illustrates the procedure of the interrupt handler 518 in flowchart forease in explanation.

The interrupt handler 518 reads the execution flag 515 (S611), andjudges whether the execution flag 515 is ON or OFF (S612). If theexecution flag 515 is ON (S612:ON), the interrupt handler 518 encryptsthe data in the memory area using the encryption/decryption keyaccording to encryption algorithm E2 (S613). After this, the interrupthandler 518 processes the interrupt. If the execution flag 515 is OFF(S612:OFF), the interrupt handler 518 processes the interrupt withoutencrypting the data in the memory area.

After processing the interrupt, if the execution flag 515 is ON(S614:ON), the interrupt handler 518 decrypts the encrypted data in thememory area using the encryption/decryption key according to decryptionalgorithm D2 (S615), before returning to original processing. If theexecution flag 515 is OFF (S614:OFF), the interrupt handler 518 returnsto the original processing without decrypting the data in the memoryarea.

-   -   -   -   (B) First Secure Processing Program 501

FIG. 10 shows a data structure of the first secure processing program501. In the drawing, the first secure processing program 501 includes adisconnection program 551, a tamper detection program 552, a keydecryption program 553, a key sending program 554, an authenticationprogram 555, a data read program 556, and a connection program 557. Thefirst secure processing program 501 is executed in a secure processingmode of the CPU 301. The secure processing mode is explained in detaillater.

-   -   -   -   -   (Disconnection Program 551)

The disconnection program 551 outputs a debugger control signalindicating “disable” to the debugger disable circuit 303, when the firstsecure processing program 501 is started.

-   -   -   -   -   (Tamper Detection Program 552)

The tamper detection program 552 contains a secret key 562, and detectswhether the second secure processing program 502 has been tampered with.To do so, the tamper detection program 552 acquires the tamper detectiondata including the tamper detection value 541, the TRS area startaddress 542, the binary size 543, and the encrypted key 544, from thecalling program 513 of the second secure processing program 502.

The tamper detection program 552 reads an amount of data correspondingto the binary size 543 from a position on the memory 305 specified bythe TRS area start address 542, as the TRS area program. The tamperdetection program 552 calculates a hash value of the TRS area programusing the secret key 562 according to the hash function. The tamperdetection program 552 compares the calculated hash value and the tamperdetection value 541. If the two values match, the tamper detectionprogram 552 judges that the second secure processing program 502 has notbeen tampered with. If the two values do not match, the tamper detectionprogram 552 judges that the second secure processing program 502 hasbeen tampered with, and discontinues subsequent processing.

-   -   -   -   -   (Key Decryption Program 553)

The key decryption program 553 contains a master key 563. If the tamperdetection program 552 judges that the second secure processing program502 has not been tampered with, the key decryption program 553 decryptsthe encrypted key 544 using the master key 563 according to decryptionalgorithm D1, to obtain the program key. The key decryption program 553passes the program key to the key sending program 554.

-   -   -   -   -   (Key Sending Program 554)

The key sending program 554 receives the program key from the keydecryption program 553, and sends the program key to the second secureprocessing program 502.

-   -   -   -   -   (Authentication Program 555)

The authentication program 555 contains an authentication key 565, andundergoes the authentication by the second secure processing program 502using the authentication key 565. If the authentication is successful,the authentication program 555 establishes a shared session key with thesecond secure processing program 502. Data which is subsequentlytransferred between the first secure processing program 501 and thesecond secure processing program 502 is encrypted using this sessionkey.

-   -   -   -   -   (Data Read Program 556)

The data read program 556 performs the mutual authentication with thememory card 400 based on CPRM. If the mutual authentication issuccessful, the data read program 556 accesses the secure area 420 ofthe memory card 400 and acquires the title key 421.

-   -   -   -   -   (Connection Program 557)

The connection program 557 outputs a debugger control signal indicating“enable”, to the debugger disable circuit 303.

-   -   -   -   (C) Vector Table 503

FIG. 11 shows a data structure of the vector table 503. As illustrated,the vector table 503 shows addresses of instructions to be executed whena software interrupt, an abort, and a hardware interrupt occur.

-   -   -   -   (D) Music Playback Program 504

The music playback program 504 plays back the music data decrypted bythe second secure processing program 502. The music playback program 504outputs the music data to a buffer 311 in the decoder 310.

-   -   -   -   (E) Application 505

The application 505 receives an input of a user operation. If the useroperation is to play back the music data on the memory card 400, theapplication 505 starts the second secure processing program 502.

-   -   -   (3) CPU 301

The CPU 301 operates according to the programs stored in the memory 305.The operation of the CPU 301 is controlled by an instruction issued fromthe debugger device connected with the debugger interface 302.

FIG. 12 is a flowchart showing an operation of the CPU 301. The CPU 301fetches an instruction of a program stored in the memory 305 (S601),decodes the instruction (S602), and executes it (S603). The CPU 301 thenincrements a program counter (S604) to fetch the next instruction.

Here, the CPU 301 operates in the secure processing mode or a normalprocessing mode. In the normal processing mode, the CPU 301 performsnormal processing. In the secure processing mode, the CPU 301 performsprocessing with a high level of security so that data in the memory 305cannot be accessed from outside.

The CPU 301 executes the first secure processing program 501 in thesecure processing mode, and the second secure processing program 502 inthe normal processing mode.

When an interrupt occurs, the interrupt controller 304 outputs aninterrupt signal via the interrupt line 318. If interrupts are disabledby the interrupt disable program 512, the CPU 301 refuses the interruptsignal. If interrupts are not disabled, the CPU 301 accepts theinterrupt signal, refers to the vector table 503 shown in FIG. 11, andreads an address corresponding to the interrupt signal. The CPU 301processes an interrupt according to an interrupt handler at the readaddress. Having processed the interrupt, the CPU 301 returns to originalprocessing.

When receiving an interrupt signal during execution of the second secureprocessing program 502, the CPU 301 refers to the vector table 503 andexecutes the interrupt handler 518 shown in FIG. 9.

-   -   -   (4) Input Unit 307

The input unit 307 receives an input of a user operation. Upon receivingthe input, the input unit 307 notifies the interrupt controller 304 ofan interrupt.

-   -   -   (5) Interrupt Controller 304

The interrupt controller 304 outputs an interrupt signal to the CPU 301via the interrupt line 318, when the input unit 307 or the radio controlunit 314 notifies the interrupt controller 304 of an interrupt such as amail reception, a call reception, or a user operation.

-   -   -   (6) Speaker 309 and Decoder 310

The decoder 310 includes the buffer 311. The buffer 311 buffers musicdata received from the CPU 301. The speaker 309 generates an audiosignal from the music data in the buffer 311, and outputs the audiosignal.

-   -   -   (7) Memory Card Interface 306

The memory card interface 306 is used to connect the portable terminal300 and the memory card 400. The memory card interface 306 outputs datato the memory card 400, and receives data from the memory card 400 andoutputs it to the CPU 301, under control of the CPU 301.

-   -   -   (8) Radio Control Unit 314, Radio Unit 315, and Antenna 316

The antenna 316, the radio unit 315, and the radio control unit 314send/receive a sound or information with a device to which the portableterminal 300 is connected via a radio base station and a portableterminal network.

When receiving a mail or a call via the antenna 316 and the radio unit315, the radio control unit 314 notifies the interrupt controller 304 ofan interrupt.

-   -   -   (9) Microphone 312 and Conversion Unit 313

The conversion unit 313 converts a sound received from the microphone312 to an electrical signal, and outputs it to the radio control unit314.

-   2. Operation of the Secure Processing System 1    -   2.1. Operation of the Certificate Authority Device 100

The compiler 101 receives an input of source code of the calling program513 and source code of the protection program, and compiles the sourcecode to binary data of the calling program 513 and binary data of theprotection program. The compiler 101 outputs the binary data to the dataembedment unit 105. The compiler 101 also receives an input of sourcecode of the decryption program 516 and source code of the secureprogram, and compiles the source code to binary data of the decryptionprogram 516 and binary data of the secure program. The compiler 101outputs the binary data to the program encryption unit 102.

The program encryption unit 102 receives the binary data of thedecryption program 516 and the binary data of the secure program. Theprogram encryption unit 102 also receives the program key. The programencryption unit 102 encrypts the secure program using the program key,to generate the encrypted program 517. The program encryption unit 102outputs the decryption program 516 and the encrypted program 517 to thedata embedment unit 105 and the hash value calculation unit 104, as theTRS area program.

The hash value calculation unit 104 receives the TRS area program. Thehash value calculation unit 104 also receives the secret key. The hashvalue calculation unit 104 calculates a hash value of the TRS areaprogram using the secret key according to the hash function. The hashvalue calculation unit 104 also calculates the binary size of the TRSarea program. The hash value calculation unit 104 outputs the hash valueand the binary size to the data embedment unit 105.

The key encryption unit 103 receives the program key and the master key,and encrypts the program key using the master key to generate theencrypted key. The key encryption unit 103 outputs the encrypted key tothe data embedment unit 105.

The data embedment unit 105 receives the binary data of the callingprogram 513 from the compiler 101, the hash value and the binary sizefrom the hash value calculation unit 104, and the encrypted key from thekey encryption unit 103. The data embedment unit 105 embeds the hashvalue in the calling program 513 as the tamper detection value 541. Thedata embedment unit 105 also embeds the binary size and the encryptedkey in the calling program 513 as the binary size 543 and the encryptedkey 544. The data embedment unit 105 further receives the binary data ofthe protection program from the compiler 101, and the TRS area programfrom the program encryption unit 102. The data embedment unit 105includes the calling program 513 in the protection program, and combinesthe protection program and the TRS area program to form the secondsecure processing program 502. The data embedment unit 105 writes thesecond secure processing program 502 to the storage unit 106.

The transmission unit 107 reads the second secure processing program 502from the storage unit 106, and outputs the second secure processingprogram 502 to the ROM writer 200.

-   -   2.2. Music Data Playback Operation of the Portable terminal 300        -   (1) Playback

An operation of playing back the music data recorded on the memory card400 by the portable terminal 300 through execution of programs isexplained below, with reference to FIGS. 13 to 17.

Upon receiving an input of a user operation to play back the music dataon the memory card 400 via the input unit 307, the application 505starts the second secure processing program 502 (S701).

In the second secure processing program 502, the area allocation program511 allocates a virtual memory space for dynamically allocating a memoryarea during execution of the secure program, in the memory 305 (S702).Also, the interrupt disable program 512 disables interrupts (S703). Inthis way, unauthorized program analysis and alteration using interruptsare prohibited. The disablement of interrupts is valid until aninterrupt enable. Next, the calling program 513 calls the first secureprocessing program 501, and passes the tamper detection data made up ofthe tamper detection value 541, the TRS area start address 542, thebinary size 543, and the encrypted key 544 to the first secureprocessing program 501 (S704).

The first secure processing program 501 receives the tamper detectiondata from the second secure processing program 502 (S705). In the firstsecure processing program 501, the disconnection program 551 outputs adebugger control signal indicating “disable” to the debugger disablecircuit 303 (S706). As a result, the debugger disable circuit 303disconnects the debugger device. In this way, unauthorized programanalysis and alteration using the debugger device are prohibited.

Next, the tamper detection program 552 performs the following procedure.

The tamper detection program 552 reads an amount of data correspondingto the binary size 543 from a position on the memory 305 specified bythe TRS area start address 542, as the TRS area program. The tamperdetection program 552 calculates a hash value of the TRS area programusing the secret key 562 (S709).

The tamper detection program 552 compares the calculated hash value withthe tamper detection value 541 (S710). If the two values do not match(S710:NO), the tamper detection program 552 judges that the secondsecure processing program 502 has been tampered with, and discontinuessubsequent processing. The connection program 557 outputs a debuggercontrol signal indicating “enable” to the debugger disable circuit 303(S737), and terminates the operation.

If the two values match (S710:YES), the tamper detection program 552judges that the second secure processing program 502 has not beentampered with. Accordingly, the key decryption program 553 decrypts theencrypted key 544 using the master key 563, to obtain the program key(S711). The key decryption program 553 passes the program key to the keysending program 554. The key sending program 554 passes the program keyto the second secure processing program 502 (S712).

In the second secure processing program 502, the key reception program514 receives the program key (S713). Also, the execution flag 515 is setto ON (S714). After this, the decryption program 516 decrypts theencrypted program 517 using the program key, to obtain the secureprogram (S715). Having done so, the decryption program 516 deletes theprogram key (S716).

The secure program performs the following procedure (S717).

In the secure program, the interrupt enable program 521 releases thedisablement of interrupts made in step 5703 (S718). Subsequently, if aninterrupt occurs, the secure program is suspended to process theinterrupt. A procedure to be performed when an interrupt occurs isexplained in detail later.

Next, the area initialization program 522 allocates a memory area inwhich data used by the authentication program 523 and the encryptedmusic data decryption program 524 is to be stored, in the memory space(S719).

The authentication program 523 authenticates the first secure processingprogram 501 according to an authentication procedure (described later)(S720). The authentication program 555 in the first secure processingprogram 501 undergoes the authentication by the authentication program523. If the authentication has failed, the second secure processingprogram 502 discontinues subsequent processing, and the connectionprogram 557 in the first secure processing program 501 outputs adebugger control signal indicating “enable” to the debugger disablecircuit 303 (S737) before terminating the operation.

If the authentication has succeeded, the second secure processingprogram 502 and the first secure processing program 501 establish ashared session key. Data which is subsequently transferred between thesecond secure processing program 502 and the first secure processingprogram 501 is encrypted using this session key.

If the authentication has succeeded, the second secure processingprogram 502 transfers control to the music playback program 504.

The music playback program 504 reads the encrypted music data 411 fromthe memory card 400 (S721). The music playback program. 504 alsorequests the second secure processing program 502 to decrypt theencrypted music data 411 (S722).

Upon receiving the request to decrypt the encrypted music data 411, thesecond secure processing program 502 calls the area encryption program526. The area encryption program 526 encrypts the data in the memoryarea allocated in step 5719, using the area key 525 (S723). After this,the second secure processing program 502 requests the first secureprocessing program 501 to acquire the title key 421 (S724).

In the first secure processing program 501, the data read program 556performs mutual authentication with the authentication unit 403 in thememory card 400 (S725). If the mutual authentication has succeeded(S726:YES), the data read program 556 accesses the secure area 420 inthe memory card 400 and acquires the title key 421 (S727). If the mutualauthentication has failed, the data read program 556 cannot acquire thetitle key 421. In this case, the connection program 557 outputs adebugger control signal indicating “enable” to the debugger disablecircuit 303 (S737), before terminating the operation.

The first secure processing program 501 encrypts the title key 421 usingthe session key, to generate an encrypted title key (S728). The firstsecure processing program 501 passes the encrypted title key to thesecond secure processing program 502.

In the second secure processing program 502, the area decryption program527 decrypts the encrypted data in the memory area using the area key525, to recover the original data (S729). The authentication program 523decrypts the encrypted title key using the session key, to obtain thetitle key 421 (S730). Following this, the encrypted music datadecryption program 524 decrypts the encrypted music data 411 read fromthe memory card 400 by the music playback program 504, using the titlekey 421 (S731). As a result, the music data is obtained. The encryptedmusic data decryption program 524 passes the music data to the musicplayback program 504.

The music playback program 504 plays back the music data (S732).

Once the playback of the music data has completed (S733), the musicplayback program 504 transfers control to the second secure processingprogram 502. In the second secure processing program 502, the arearelease program 528 releases the memory area allocated in step S719(S734), and calls an exit function of the first secure processingprogram 501 (S735). Also, the execution flag 515 is set to OFF (S736).

In the first secure processing program 501, the connection program 557outputs a debugger control signal indicating “enable” to the debuggerdisable circuit 303 (S737), before terminating the operation.

-   -   -   -   (2) Authentication

The procedure of authenticating the first secure processing program 501by the second secure processing program 502 in step S720 is explainedbelow, with reference to FIG. 18.

The second secure processing program 502 generates random number R0, andpasses random number R0 to the first secure processing program 501(S751).

The first secure processing program 501 receives random number R0, andencrypts random number R0 using the authentication key 565 to generateauthentication value R1 (S752). The first secure processing program 501passes authentication value R1 to the second secure processing program502 (S753).

The second secure processing program 502 receives authentication valueR1 from the first secure processing program 501. The second secureprocessing program 502 encrypts random number RO using theauthentication key 531, to generate authentication value R2 (S754). Thesecond secure processing program 502 compares authentication value R1with authentication value R2 (S755). If the two values do not match(S755:NO), the second secure processing program 502 passes a judgmentresult indicating “mismatch” to the first secure processing program 501(S756), and terminates the procedure. If the two value match (S755:YES),the second secure processing program 502 passes a judgment resultindicating “match” to the first secure processing program 501 (S757).The second secure processing program 502 then generates the session keyfrom random number RO and authentication key 531 using a one-wayfunction (S759).

If the received judgment result indicates “mismatch” (S758:NO), thefirst secure processing program 501 terminates the procedure. If thereceived judgment result indicates “match” (S758:YES), the first secureprocessing program 501 generates the session key from random number R0and authentication key 565 using the one-way function (S760).

Thus, the second secure processing program 502 authenticates the firstsecure processing program 501, and shares the session key if theauthentication is successful. Data which is subsequently transferredbetween the first secure processing program 501 and the second secureprocessing program 502 is encrypted using this session key.

-   -   -   -   (3) Interrupt

The operation of the CPU 301 when an interrupt occurs during executionof the second secure processing program 502 is explained below, withreference to FIG. 19. Here, the interrupt is a mail reception as oneexample.

Upon receiving an interrupt signal from the interrupt controller 304(S771), the CPU 301 reads the vector table 503 (S772), and executes theinterrupt handler 518 according to the vector table 503 (S773).

First, the CPU 301 reads the execution flag 515 (S774). If the executionflag 515 is ON (S775:0N), the CPU 301 encrypts the data in the memoryarea using the encryption/decryption key (S776). The CPU 301 also savesa context (S777), and performs a mail reception process (S778). If theexecution flag 515 is OFF (S775:OFF), the CPU 301 performs steps 5777and 5778 without encrypting the data in the memory area.

After the mail reception process, if the execution flag 515 is ON(S779:0N), the CPU 301 decrypts the data in the memory area (S780),before returning to original processing. If the execution flag 515 isOFF (S779:OFF), the CPU 301 returns to the original processing withoutdecrypting the data in the memory area.

-   3. Modifications

The present invention has been described by way of the above embodiment,though it should be obvious that the present invention is not limited tothe above. Example modifications are given below.

-   -   (1) The above embodiment de scribes an example of protecting an        encrypted music data decryption program which is executed by a        portable terminal, though the present invention is not limited        to such.

Example devices which execute a program to be protected include a DVDplayer, a DVD recorder, a PC, and a PDA.

Also, example programs to be protected include a decryption program usedwhen playing back video content or a game on a portable terminal, and arecording program used when recording content on a DVD recorder. Thus,the present invention is applicable to any program that need beprotected against unauthorized analysis and alteration.

-   -   (2) The above embodiment describes the case where a hash value        is used as the tamper detection value, though any value that is        unique to the TRS area program can be used as the tamper        detection value. For instance, a digital signature for the TRS        area program or data generated by encrypting the TRS area        program may be used as the tamper detection value. Also,        algorithms other than the one used in the embodiment may be        employed to calculate the hash value.

The above embodiment describes the case where the tamper detection valueis generated for the TRS area program, but the tamper detection valuemay instead be generated for at least one part of the TRS area program.Alternatively, the tamper detection value may be generated for at leastone part of the second secure processing program.

Also, the tamper detect ion may be carried out by per forming matchingfor at least one part of the TRS area program or the second secureprocessing program, or by embedding a pseudo-random number in at leastone part of the TRS area program or the second secure processingprogram. In other words, any tamper detection method that can detectwhether a program has been tampered with is applicable.

The above embodiment describes the case where the tamper detection isperformed after the debugger disable circuit disconnects the debuggerdevice. As an alternative, the tamper detection may be performed beforethe disconnection by the debugger disable circuit. In such a case, if notampering is detected, the debugger disable circuit disconnects thedebugger device to proceed to subsequent processing.

-   -   (3) The above embodiment describes the case where the calling        program in the second secure processing program passes the        tamper detect ion data to the first secure processing program.        As an alternative, a program other than the second secure        processing program may pass the tamper detection data to the        first secure processing program. In this case, the calling        program in the second secure processing program only calls the        first secure processing program. Meanwhile, a sending program        for sending the tamper detection data to the first secure        processing program is stored in the memory 305. This being so,        upon being called by the second secure processing program, the        first secure processing program requests the sending program to        send the tamper detection data. The sending program responsively        sends the tamper detection data to the first secure processing        program.

In such a case, the certificate authority device does not include thissending program in the protection program of the second secureprocessing program, but generates it separately from the second secureprocessing program.

Also, the first secure processing program may contain the tamperdetection data of the second secure processing program beforehand.

-   -   (4) The above embodiment describes the case where the second        secure processing program performs one-way authentication on the        first secure processing program, but the second secure        processing program and the first secure processing program may        perform two-way authentication. Also, the above embodiment        describes the use of a challenge-response authentication method,        though other authentication methods for authenticating a program        can equally be used.

The above embodiment describes the case where authentication values R1and R2 are generated by encrypting random number R0 using theauthentication key, but they may instead be generated by applying aone-way function to random number R0.

The above embodiment describes the case where the session key isgenerated from random number R0 and the authentication key using aone-way function, though the session key may instead be generated byencryption.

-   -   (5) The above embodiment describes the case where the area        encryption program encrypts the data in the memory area before        control is transferred from the second secure processing program        to the first secure processing program. The area encryption        program may also encrypt the data in the memory area to protect        the data, when control is transferred from the second secure        processing program to another program such as when the second        secure processing program calls an external function.

In such a case, when control is returned to the second secure processingprogram, the area decryption program decrypts the encrypted data in thememory area to recover the original data.

-   -   (6) A unique master key may be assigned to each device which        executes a program to be protected. In this case, even if an        unauthorized user steals a master key of one device and attempts        to attack other devices using the master key, the unauthorized        user cannot operate the other devices properly. This minimizes        damage caused by unauthorized acts.    -   (7) The above embodiment describes the case where the first        secure processing program and the second secure processing        program each contain the authentication key. Alternatively, the        authentication key may be calculated based on the program key or        the tamper detection value.

Also, the certificate authority device may encrypt the authenticationkey using the master key. In this case, the program key for decryptingthe encrypted program can be calculated based on the authentication key.

When the key used for authentication and the key used for decryption ofthe encrypted program have a dependency relationship in this way, any ofthe keys may be encrypted. Further, multiple encryption stages may beperformed using a greater number of keys, such as by encrypting theencrypted key using another key.

-   -   (8) The present invention also applies to the method described        above. This method may be realized by a computer program that is        executed by a computer. Such a computer program may be        distributed as a digital signal.

The present invention may be realized by a computer-readable storagemedium, such as a flexible disk, a hard disk, a CD-ROM, an MO, a DVD, aDVD-ROM, a DVD-RAM, a BD, or a semiconductor memory, on which thecomputer program or digital signal mentioned above is recorded.Conversely, the present invention may also be realized by the computerprogram or digital signal that is recorded on such a storage medium.

The computer program or digital signal that achieves the presentinvention may also be transmitted via a network, such as an electroniccommunications network, a wired or wireless communications network, orthe Internet.

The present invention can also be realized by a computer system thatincludes a microprocessor and a memory. In this case, the computerprogram can be stored in the memory, with the microprocessor operatingin accordance with this computer program.

The computer program or digital signal may be provided to an independentcomputer system by distributing a storage medium on which the computerprogram or digital signal is recorded, or by transmitting the computerprogram or digital signal via a network. The independent computer systemmay then execute the computer program or digital signal to function asthe present invention.

-   -   8) The above embodiment and modifications may be freely        combined.

INDUSTRIAL APPLICABILITY

The present invention can be used recurrently and continuously insoftware industries which provide software such as computer programs anddigital content of movies, music, and the like. Also, the presentinvention can be manufactured and sold in manufacturing industries ofelectrical products and the like.

1-12. (canceled)
 13. An encrypted digital content playback devicecomprising: a program execution unit configured to execute a programwhile switching between a first mode indicating an operating state in afirst security level and a second mode indicating an operating state ina second security level lower than the first security level; and anexternal device disconnection unit configured to disconnect the programexecution unit from an external device when the program is executed inthe first mode, wherein a first secure program is executed in the firstmode, a second secure program is different from the first secure programand runs in the second security level, an application program starts thesecond secure program according to a digital content playbackinstruction from a user, the first secure program obtains a content keyfor decrypting encrypted digital content according to an instructionfrom the second secure program after the external device disconnectionunit disconnects the program execution unit from the external device,and the second secure program causes digital content to be played backusing a buffer.
 14. The encrypted digital content playback device ofclaim 13, wherein the first secure program retains secret informationused by the second secure program, and the program execution unit,according to the first secure program, performs mutual authenticationwith the second secure program, establishes a common session key withthe second secure program, encrypts the secret information using thesession key, and passes the encrypted secret information to the secondsecure program.
 15. The encrypted digital content playback device ofclaim 14, wherein the secret information retained by the first secureprogram is key information obtained from a secure area of an externalstorage medium.
 16. The encrypted digital content playback device ofclaim 14, wherein the program execution unit, according to the firstsecure program, performs a hash operation on at least one part of thesecond secure program using a secret key to calculate a first tamperdetection value, compares the first tamper detection value with a secondtamper detection value which has been calculated based on the at leastone part of the second secure program upon generation of the secondsecure program, and terminates the operation if the first tamperdetection value and the second tamper detection value are different, andcontinues the operation if the first tamper detection value and thesecond tamper detection value are same.
 17. The encrypted digitalcontent playback device of claim 16, wherein the second secure programincludes a call instruction for calling the first secure program, andthe program execution unit, according to the call instruction, passesthe second tamper detection value, a start address of the at least onepart of the second secure program, and a size of the at least one partof the second secure program, to the first secure program.
 18. Theencrypted digital content playback device of claim 17, wherein theprogram execution unit, (a) according to the call instruction includedin the second secure program, passes an encrypted program key to thefirst secure program, (b) according to the first secure program,decrypts the encrypted program key received from the second secureprogram using a master key included in the first secure program, andpasses the decrypted program key to the second secure program, if thefirst tamper detection value and the second tamper detection value aresame, and (c) according to the second secure program, decrypts anencrypted part of the second secure program using the decrypted programkey received from the first secure program, and then deletes thedecrypted program key, and the encrypted digital content playback devicefurther comprising a protection unit configured to disable interruptprocessing performed by the program execution unit before the programexecution unit executes the call instruction, and enable the interruptprocessing performed by the program execution unit after the programexecution unit deletes the decrypted program key.
 19. The encrypteddigital content playback device of claim 18, further comprising aninterrupt detection unit configured to detect an interrupt, wherein theprotection unit includes a memory area to which the program executionunit writes data when operating according to the second secure program,and when the interrupt detection unit detects an interrupt while theprogram execution unit is operating according to the second secureprogram, the protection unit encrypts the data written to the memoryarea, and, after the program execution unit finishes interruptprocessing, decrypts the encrypted data before the program executionunit resumes operating according to the second secure program.
 20. Theencrypted digital content playback device of claim 13, wherein the firstsecure program passes, to the second secure program, executioninformation that is necessary for execution of the second secureprogram.
 21. The encrypted digital content playback device of claim 20,wherein at least one part of the second secure program has beenencrypted, the execution information retained by the first secureprogram is a program key used to decrypt an encrypted part of the secondsecure program, and the program execution unit passes the program key tothe second secure program according to the first secure program, anddecrypts and executes the encrypted part of the second secure programusing the program key obtained from the first secure program accordingto the second secure program.
 22. A secure program used in an encrypteddigital content playback device, wherein the secure program includes afirst secure program that runs in a first security level and confirmswhether other program has been tampered with, and a second secureprogram that runs in a second security level lower than the firstsecurity level, the first and second secure programs associate with eachother to operate as a single application program, the encrypted digitalcontent playback device comprising: a program execution unit configuredto execute the first secure program in a first mode indicating anoperating state in the first security level, and the second secureprogram in a second mode indicating an operating state in the secondsecurity level, while switching between the first and second modes; andan external device disconnection unit configured to disconnect theprogram execution unit from an external device when the first secureprogram is executed, the secure program causes the program executionunit to perform: a step of instructing, by the first secure program, theexternal device disconnection unit to disconnect the program executionunit from the external device; a step of confirming, by the first secureprogram, whether the second secure program has been tampered with afterthe program execution unit is disconnected from the external device; anda step of executing a part of the second secure program only when it isconfirmed that the second secure program has not been tampered with as aresult of the confirmation.
 23. A computer-readable storage mediumstoring a secure program used in an encrypted digital content playbackdevice, wherein the secure program includes a first secure program thatruns in a first security level and confirms whether other program hasbeen tampered with, and a second secure program that runs in a secondsecurity level lower than the first security level, the first and secondsecure programs associate with each other to operate as a singleapplication, the encrypted digital content playback device comprising: aprogram execution unit configured to execute the first secure program ina first mode indicating an operating state in the first security level,and the second secure program in a second mode indicating an operatingstate in the second security level, while switching between the firstand second modes; and an external device disconnection unit configuredto disconnect the program execution unit from an external deviceaccording to an instruction from the first secure program, the secureprogram causes the program execution unit to perform: a step ofinstructing, by the first secure program, the external devicedisconnection unit to disconnect the program execution unit from theexternal device; a step of confirming, by the first secure program,whether the second secure program has been tampered with after theprogram execution unit is disconnected from the external device; and astep of executing a part of the second secure program only when it isconfirmed that the second secure program has not been tampered with as aresult of the confirmation.
 24. A program execution method used in anencrypted digital content playback device executing a secure program,wherein the secure program includes a first secure program that runs ina first security level and confirms whether other program has beentampered with, and a second secure program that runs in a secondsecurity level lower than the first security level, the first and secondsecure programs associate with each other to operate as a singleapplication, the encrypted digital content playback device comprising: aprogram execution unit configured to execute the first secure program ina first mode indicating an operating state in the first security level,and the second secure program in a second mode indicating an operatingstate in the second security level, while switching between the firstand second modes; and an external device disconnection unit configuredto disconnect the program execution unit from an external deviceaccording to an instruction from the first secure program, the programexecution method comprising: a step of instructing, by the first secureprogram, the external device disconnection unit to disconnect theprogram execution unit from the external device; a step of confirming,by the first secure program, whether the second secure program has beentampered with after the program execution unit is disconnected from theexternal device; and a step of executing a part of the second secureprogram only when it is confirmed that the second secure program has notbeen tampered with as a result of the confirmation.